/**
 * @(#) ActuatorMode.java
 */

package pcsr.hwVirtualization;

import java.util.List;

/**
 * Operating mode of an actuator.
 * @author Paulo Fagundes
 *
 */
public class ActuatorMode
{
	private java.util.List<String> availableModes;
	
	private String selectedMode;

	/**
	 * {@inheritDoc}
	 */
	public boolean equals(Object obj)
	{
		if(obj == null)
		{
			return false;
		}
		
		if(!(obj instanceof ActuatorMode) )
		{
			return false;
		}
		
		ActuatorMode amObj = (ActuatorMode)obj;		
		if(
				(selectedMode != null && !selectedMode.equals(amObj.selectedMode)) ||
				(availableModes != null && !availableModes.equals(amObj.availableModes))
			)
		{
			return false;
		}
		
		return true;
	}

	/**
	 * Gets all operating modes a specific actuator can handle.
	 * @return The availableModes
	 */
	public List<String> GetAvailableModes( ) {
		return availableModes;
	}

	/**
	 * Gets the operating mode which the actuator is using.
	 * @return The selectedMode
	 */
	public String GetSelectedMode( ) {
		return selectedMode;
	}

	/**
	 * Sets a list of all operating modes an actuator can operate.
	 * <p><strong>Remarks:</strong> This method is for driver use only.</p>
	 * @param availableModes The availableModes to set
	 */
	public void SetAvailableModes( List<String> availableModes ) {
		this.availableModes = availableModes;
	}
	
	/**
	 * Sets a new operating mode.
	 * @param selectedMode The selectedMode to set
	 */
	public void SetSelectedMode( String selectedMode ) {
		if(availableModes.contains(selectedMode))
		{
			this.selectedMode = selectedMode;
		}
	}
}
